home *** CD-ROM | disk | FTP | other *** search
Text File | 1988-01-08 | 7.0 KB | 280 lines | [TEXT/PJMM] |
- UNIT MyPlotStuff;
-
- INTERFACE
-
- USES
- ROM85, PrintTraps, PlotGlobals, Misc, solve, MyFileStuff, MyPrintStuff;
-
- PROCEDURE doAbout;
- PROCEDURE doQuit;
- PROCEDURE doMenubar (menuResult : LongInt);
- PROCEDURE doContent (ConEvent : EventRecord;
- contentWindow : windowPtr);
- PROCEDURE doDrag (GrabWindow : WindowPtr;
- GlobalMouse : point);
- PROCEDURE doGrow (ResizeWindow : WindowPtr;
- Globalmouse : point;
- Zoomflg : Boolean);
-
- IMPLEMENTATION
-
- PROCEDURE doAbout;
- VAR
- IDStrHandle : StringHandle;
- dialogP : DialogPtr;
- item : integer;
- Str1, Str2, Str3 : str255;
- myHeapSpace : LongInt;
- FreeSpace : Size;
- BEGIN
- IDStrHandle := StringHandle(GetResource(rsrc, 0));
- IF IDStrHandle = NIL THEN
- BEGIN
- doMessage('Get About box crash!', '', '', '');
- ExitToShell;
- END;
- MoveHHi(Handle(IDStrHandle));
- HLock(Handle(IDStrHandle));
- FreeSpace := FreeMem;
- myHeapSpace := MaxMem(FreeSpace);
- NumToString(myHeapSpace, Str2);
- Str2 := concat('Memory = ', Str2);
- Str3 := '';
- Str1 := '';
- ParamText(IDStrHandle^^, Str1, Str2, Str3);
- dialogP := GetNewDialog(AboutDialog, NIL, pointer(-1));
- IF dialogP = NIL THEN
- BEGIN
- doMessage('Dialog crash!', 'We are dead...', '', '');
- ExitToShell;
- END;
- initCursor;
- ModalDialog(NIL, item);
- DisposDialog(dialogP);
- HUnlock(Handle(IDStrHandle));
- END;
-
- PROCEDURE doQuit;
- BEGIN
- BackColor(whiteColor);
- ForeColor(blackColor);
- PenNormal;
- DisposeWindow(PlotWindow);
- DisposeRgn(mouseRgn);
- DisposHandle(Handle(PlotDocHandle));
- Finished := true;
- END; {of proc}
-
- PROCEDURE doMenubar; {(menuResult : LongInt)}
- VAR
- theMenu : integer;
- theItem : integer;
- daName : STR255;
- accItem : integer;
- temp : GrafPtr;
- BEGIN
- theMenu := HiWord(menuResult); {menu}
- theItem := LoWord(menuResult); {item}
- CASE theMenu OF
- AppleMenu :
- BEGIN
- IF theItem = aAbout THEN
- doAbout
- ELSE
- BEGIN {must be DA}
- GetItem(myMenus[AppleM], theItem, daName);
- GetPort(temp); {protect against flacky DA}
- accItem := OpenDeskAcc(daName);
- SetPort(temp);
- END; {else}
- END; {of AppleMenu}
- FileMenu :
- BEGIN
- CASE theItem OF
- fPlot :
- BEGIN
- doPlot;
- END;
- fSave :
- BEGIN
- doSave;
- END;
- fSaveAs :
- BEGIN
- doSaveAs;
- END;
- fPageSet :
- BEGIN
- doPageSet;
- END;
- fPrint :
- BEGIN
- doPrint;
- END;
- fQuit :
- BEGIN
- doQuit;
- END;
- OTHERWISE
- BEGIN
- END;
- END; {of theitem}
- END; {of FileMenu}
- EditMenu :
- BEGIN
- IF NOT SystemEdit(theitem - 1) THEN
- BEGIN
- CASE theItem OF
- eUndo :
- BEGIN
- END;
- eCut :
- BEGIN
- END;
- eCopy :
- BEGIN
- END;
- ePaste :
- BEGIN
- END;
- eClear :
- BEGIN
- END;
- OTHERWISE
- BEGIN
- END;
- END; {of case}
- END; {of system edit}
- END; {of EditMenu}
- ColorMenu :
- BEGIN {just a dummy for submenus}
- END; {of color menu}
- GraphMenu :
- BEGIN
- CheckItem(myMenus[GraphM], GraphColor, false);
- GraphColor := theitem;
- CheckItem(myMenus[GraphM], GraphColor, true);
- END; {of graph menu}
- AxisMenu :
- BEGIN
- CheckItem(myMenus[AxisM], AxisColor, false);
- AxisColor := theitem;
- CheckItem(myMenus[AxisM], AxisColor, true);
- END; {of axis menu}
- BackgroundMenu :
- BEGIN
- CheckItem(myMenus[BackgroundM], BackgroundColor, false);
- BackgroundColor := theitem;
- CheckItem(myMenus[BackgroundM], BackgroundColor, true);
- END; {of background menu}
- OptionMenu :
- BEGIN
- CheckItem(myMenus[OptionM], Option, false);
- Option := theitem;
- CheckItem(myMenus[OptionM], Option, true);
- END;
- OTHERWISE
- BEGIN
- END;
- END; {of theMenu}
- HiliteMenu(0); {un-hilite selected menu}
- END;
-
- PROCEDURE doContent; {(ConEvent : EventRecord}
- {contentWindow : windowPtr);}
- VAR
- localPt, globalPt : Point;
- part : integer;
- myRect : Rect;
- control : ControlHandle;
- BEGIN
- IF contentWindow <> FrontWindow THEN
- SelectWindow(contentWindow);
- globalPt := ConEvent.where;
- localPt := globalPt; {global coord of mouse}
- GlobalToLocal(localPt); {local coord of mouse}
- part := FindControl(localPt, contentWindow, control);
-
- IF contentWindow = PlotWindow THEN
- BEGIN
- SetPort(PlotWindow);
- IF part <> 0 THEN
- BEGIN {in control}
- END;
- IF part = 0 THEN
- BEGIN {content region}
- myRect := PlotWindow^.portRect;
- IF PtInRect(localPt, myRect) THEN
- BEGIN
- END; {of ptInRect}
- END; { of part=0 }
- END; {of contentwindow}
- END; {of proc}
-
- PROCEDURE doDrag; {(GrabWindow : WindowPtr}
- {GlobalMouse : point);}
- BEGIN
- DragWindow(GrabWindow, GlobalMouse, DragArea);
- END;
-
- PROCEDURE doGrow; {(ResizeWindow : WindowPtr;}
- {Globalmouse : point;}
- {ZoomFlg:Boolean);}
- VAR
- newSize : LongInt;
- hsize : integer;
- vsize : integer;
- oldPort : GrafPtr;
- myRect : rect;
- tempLong : LongInt;
- BEGIN
- IF (ResizeWindow <> FrontWindow) THEN
- SelectWindow(ResizeWindow)
- ELSE
- BEGIN
- IF (ZoomFlg) THEN
- BEGIN
- WITH ResizeWindow^.portRect DO
- BEGIN
- tempLong := bottom - top;
- newSize := BitShift(tempLong, 16);
- newSize := newSize + (right - left);
- END;
- END
- ELSE
- newSize := GrowWindow(ResizeWindow, Globalmouse, GrowArea);
- IF newSize <> 0 THEN
- BEGIN {grow the window}
- hsize := LoWord(newSize);
- vsize := HiWord(newSize);
- IF ResizeWindow = PlotWindow THEN
- BEGIN
- WITH ResizeWindow^.portRect DO {Pre-Grow}
- BEGIN
- SetRect(VCRect, right - (SBarWidth - 1), top - 1, right + 1, bottom - (SBarWidth - 2));
- SetRect(HCRect, left - 1, bottom - (SBarWidth - 1), right - (SBarWidth - 2), bottom + 1);
- SetRect(GrowRect, HCRect.right, HCRect.top, VCRect.right, HCRect.bottom);
- SetRect(PicRect, left, top, right - (SBarWidth - 1), bottom - (SBarWidth - 1));
- END; {of with }
- InvalRect(VCRect);
- InvalRect(HCRect);
- InvalRect(GrowRect);
- SizeWindow(ResizeWindow, hsize, vsize, TRUE); {new portRect}
- WITH ResizeWindow^.portRect DO {Post Grow}
- BEGIN
- SetRect(VCRect, right - (SBarWidth - 1), top - 1, right + 1, bottom - (SBarWidth - 2));
- SetRect(HCRect, left - 1, bottom - (SBarWidth - 1), right - (SBarWidth - 2), bottom + 1);
- SetRect(GrowRect, HCRect.right, HCRect.top, VCRect.right, HCRect.bottom);
- SetRect(PicRect, left, top, right - (SBarWidth - 1), bottom - (SBarWidth - 1));
- SetRect(PageRect, left, top, right - (SBarWidth - 1), bottom - (SBarWidth - 1));
- END; {of with }
- InvalRect(VCRect);
- InvalRect(HCRect);
- InvalRect(GrowRect);
- InvalRect(PicRect);
- END; {of if ResizeWindow}
- END; {of grow window stuff}
- END; {of if then newsize}
- END; { of proc }
-
- END. {of unit}